import request from '@/utils/request'


// 查询公告列表
export function listAnnouncement(query) {
  return request({
    url: '/admin/announcement/list',
    method: 'get',
    params: query
  })
}


// 删除公告
export function delAnnouncement(id) {
  return request({
    url: '/admin/announcement/deleteAnnouncement/' + id,
    method: 'delete'
  })
}

//根据id获取公告
export function getAnnouncement(id) {
  return request({
    url: '/admin/announcement/getAnnouncement/' + id,
    method: 'get'
  })
}


// 发公告之图片上传
export function uploadImg(img) {
  const formData = new FormData();
  formData.append('img', img);
  return request({
    url: '/admin/announcement/uploadImg',
    headers: { 'Content-Type': 'multipart/form-data' },
    method: 'post',
    data: formData,
  });
}

// 新增公告
export function addAnnouncement(data) {
  return request({
    url: '/admin/announcement/addAnnouncement',
    method: 'post',
    data: data,
  });
}

// 新增公告
export function updateAnnouncement(data) {
  return request({
    url: '/admin/announcement/updateAnnouncement',
    method: 'put',
    data: data,
  });
}

